/********************************** (C) COPYRIGHT *******************************
 * File Name          : main.c
 * Author             : WCH
 * Version            : V1.0
 * Date               : 2020/08/06
 * Description        :
 *********************************************************************************
 * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
 * Attention: This software (modified or not) and binary are used for 
 * microcontroller manufactured by Nanjing Qinheng Microelectronics.
 *******************************************************************************/

/******************************************************************************/
/* Header file contains */
#include "CONFIG.h"
#include "HAL.h"
#include "RF_PHY.h"
#include  "center_node.h"



/*********************************************************************
 * GLOBAL TYPEDEFS
 */
__attribute__((aligned(4))) uint32_t MEM_BUF[BLE_MEMHEAP_SIZE / 4];

u32  test_cn=0;

#if(defined(BLE_MAC)) && (BLE_MAC == TRUE)
const uint8_t MacAddr[6] = {0x84, 0xC2, 0xE4, 0x03, 0x02, 0x02};
#endif

/*********************************************************************
 * @fn      Main_Circulation
 *
 * @brief   Main loop
 *
 * @return  none
 */
__attribute__((section(".highcode")))
__attribute__((noinline))
void Main_Circulation(void)
{
    while(1)
    {
        TMOS_SystemProcess();


    }
}





void GPIO_Toggle_INIT(void)
{
    GPIO_InitTypeDef GPIO_InitStructure = {0};

    RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOA, ENABLE);


    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_Init(GPIOA, &GPIO_InitStructure);

    GPIO_WriteBit(GPIOA, GPIO_Pin_10, Bit_SET);
}
/*********************************************************************
 * @fn      main
 *
 * @brief   Main function
 *
 * @return  none
 */
int main(void)
{
    SystemCoreClockUpdate();
    Delay_Init();

#ifdef DEBUG
    USART_Printf_Init(1500000  ); //115200
#endif
//    while(0){
//        Delay_Ms(10);
//
//      PRINT("%s\n", VER_LIB);
//
//    }


    WCHBLE_Init();
    HAL_Init();



    DMA_INIT();
    USARTx_CFG();

    Delay_Ms(1);



//    PRINT_DMA(  SNIPRINTF( txUartDmaBuffer,  sizeof(txUartDmaBuffer),  "test:%x\n",16));
//
//    Delay_Ms(1);
//    print_dma("test1:%x\n  c%",16  , 'c');


    // GPIO_Toggle_INIT( );
    LL_SetTxPowerLevel(LL_TX_POWEER_7_DBM);

    TIM2_INIT();

    RF_RoleInit();
    RF_Init();
    Main_Circulation();
}

/******************************** endfile @ main ******************************/
